


	var app = new Vue({
	  el: '#app',
	  data: {
        controller: {
            isPhotoCon: false,
            alertText: false
        },
        basicsInformationId: 0,
        

        leisureTime:{
            readyStart:'',
            readyEnd:'',
            timeList:[]
        },


	  },
       methods: {
       
       
       
        AddTimeList:function() {
            if (this.leisureTime.readyStart != '' && this.leisureTime.readyEnd != '') {
                this.leisureTime.timeList.unshift({starttime:this.leisureTime.readyStart, id:0, endtime: this.leisureTime.readyEnd});
                this.leisureTime.readyStart = '';
                this.leisureTime.readyEnd = '';

            }else{
                console.log('请填写正确的日期！')
                this.AlertConFun('请填写正确的日期！')
            }
        },

        deleteTimeList:function(index, item) {
            console.log(item.id);

            if (item.id != 0) {
                console.log('请求删除 服务器 数据');

                axios.get(severUrl + 'delNeutral?id='+item.id).then(function(response) {
                   if (response.data.success) {
                        app.leisureTime.timeList.splice(index, 1);
                        app.AlertConFun('删除成功！')
                    }

                });

            }else{
                this.leisureTime.timeList.splice(index, 1);
                this.AlertConFun('删除成功！')

            }

        },

       
        //提交信息
        submitDataInfo:function(){
            var dataInfo = {
                houseworker_id: app.basicsInformationId,
                LeisureTime: app.leisureTime.timeList,

            }
            
            axios({
              method: 'post',
              url: severUrl + 'addLeisureTime',
              data: dataInfo,
            })
            .then(function(response) {
                window.location.href = 'index.html';

            });
        },
        AlertConFun: function(string) {
            this.controller.alertText = string;

            setTimeout(function(argument) {
                this.app._data.controller.alertText = false;
            },1500)

        },
      },
       watch: {  
        
        
       },
       created: function (){
            console.log('加载')
            var phone = loginObj.getLogoinInfo() || 0;
            // var phone = 15;
            axios.get(severUrl+'getHouseworker?phone=' + phone).then(function(response) {
                var data = response.data;
                //如果之前填写过信息
                if (data.isEmpty) {
                    //空档期
                    if (data.Personal) {
                        //个人资料
                        app.basicsInformationId = data.Personal.id;
                    }
                    if (data.LeisureTime) {
                        app.leisureTime.timeList = data.LeisureTime;
                    }
                }
                
            });
        }

	})
















	 
	